// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class Star extends cc.Component {

    @property([cc.SpriteFrame])
    skins: cc.SpriteFrame[] = []
    
    // onLoad () {}

    // start () {}

    // update (dt) {}

    /**
     * 初始化star
     */
    initHandler(skinIndex: number): number{
        if(this.skins.length <= 0){
            console.warn('缺少 skins 皮肤图集')
            return;
        }
        const frame: cc.SpriteFrame = this.skins[skinIndex]
        this.node.getComponent(cc.Sprite).spriteFrame = frame;

        return skinIndex
    }
}
